package com.comut.crud.ejb;

import com.comut.crud.bo.ReportHandler;
import com.comut.crud.connection.MooveFleetConnectionManager;
import com.comut.crud.ejb.interfaces.local.IReportActionLocal;
import com.comut.crud.ejb.interfaces.remote.IReportActionRemote;
import com.comut.crud.pojo.mobile.ReportInfo;
import java.sql.Connection;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.jws.WebMethod;
import javax.jws.WebService;

/**
 * Issue: IFL-1571
 * 
 * @author celia calcada
 */
@Stateless
@WebService
public class ReportBean implements IReportActionRemote, IReportActionLocal {
    private static Logger _logger = Logger.getLogger(ReportBean.class.getName());

    @WebMethod
    public ReportInfo[] getReportsUserId(int userId,String language) {
        ReportInfo[] ret = null;
        Connection connection = null;
        ReportHandler reportHandler;

        try {
            connection = MooveFleetConnectionManager.instance().getConnection();
            reportHandler = new ReportHandler(connection);
            ret = reportHandler.getReportsUserId(userId, language);
        } finally {
            MooveFleetConnectionManager.instance().freeConnection(connection);
            reportHandler = null;
        }

        return ret;        
    }
    
}
